package com.ktgj.flight.api.factory;

import com.ktgj.common.core.domain.R;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.flight.api.RemoteFlightService;
import com.ktgj.flight.api.domain.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;

import javax.naming.NameParser;
import java.util.List;
import java.util.Map;

@Component
public class RemoteFlightFallbackFactory implements FallbackFactory<RemoteFlightService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteFlightFallbackFactory.class);

    @Override
    public RemoteFlightService create(Throwable cause) {
        log.error("机场服务调用失败:{}", cause.getMessage());
        return new RemoteFlightService() {

            @Override
            public R<AirportTerminalApi> getAirportTerminal(Long terminalId) {
                return R.fail("获取航站楼失败" + cause.getMessage());
            }

            @Override
            public String queryStartTerminal(Long terminalId) {
                log.error("获取航站楼失败", cause.getMessage());
                return null;
            }

            @Override
            public String queryAirPortName(String airportId) {
                log.error("获取机场名称失败", cause.getMessage());
                return null;
            }

            @Override
            public Map<String, Object> queryFlightOrderTrip(Long orderID) {
                log.error("获取机票订单明细失败", cause.getMessage());
                return null;
            }

            @Override
            public List<FlightResponseVoApi> getFlightInfoListBySearchConditions(MoFlightSearchRequestApi searchRequest) {
                log.error("获取机票列表失败", cause.getMessage());
                return null;
            }

            @Override
            public String queryAirlinerByAirlinerId(String airlinerId) {
                log.error("获取航空公司名称失败", cause.getMessage());
                return null;
            }

            @Override
            public FightStopResVoApi getFightInfoByAirCodeAndDate(FightStopReqVoApi vo) {
                log.error("获取航班信息失败", cause.getMessage());
                return null;
            }

            @Override
            public List<TicketOrderApi> checkTheTicketList(Long customerId) {
                log.error("获取机票订单信息失败", cause.getMessage());
                return null;
            }

            @Override
            public Map<String, Object> queryInfoTickets(Long customerId) {
                log.error("获取机票信息失败！", cause.getMessage());
                return null;
            }

            @Override
            public int queryFlightOrderNumber(Long customerId) {
                log.error("获取用户有多少机票订单失败！", cause.getMessage());
                return 0;
            }

            @Override
            public JourneyFlightOrderInfoVoApi journeyFlightOrderInfo(Map<String, Object> map) {
                log.error("获取行程机票订单失败！", cause.getMessage());
                return null;
            }

            @Override
            public List<AirportApi> selectAirportLike(Map<String, Object> map) {
                log.error("获取城市三字码失败！", cause.getMessage());
                return null;
            }

            @Override
            public List<AirportApi> selectAirportName(Map<String, Object> map) {
                log.error("获取城市名称失败！", cause.getMessage());
                return null;
            }

            @Override
            public List<FlightOrderInfoTicketsApi> selFlightOrderInfoById(Map<String, Object> map) {
                log.error("获取机票订单失败！", cause.getMessage());
                return null;
            }

            @Override
            public List<FlightOrderInfoTicketsApi> selFlightOrderInfo(FlightOrderInfoTickets flightOrderInfoTickets) {
                log.error("获取机票订单失败！", cause.getMessage());
                return null;
            }

//            @Override
//            public AirportApi airportName(Map<String, Object> map) {
//                log.error("获取机场名称失败！", cause.getMessage());
//                return null;
//            }

            @Override
            public AirportApi getAirportInfoByAirportName(Map<String, Object> map) {
                log.error("获取机场名三字码！", cause.getMessage());
                return null;
            }

            @Override
            public String airportNameById(Map<String, Object> map) {
                log.error("获取机场名称失败", cause.getMessage());
                return null;
            }

            @Override
            public AirportTerminalApi getInfoById(Map<String, Object> map) {
                log.error("获取航站楼名称失败", cause.getMessage());
                return null;
            }

            @Override
            public AirportTerminalApi getInfoByName(Map<String, Object> map) {
                log.error("获取航站楼id失败", cause.getMessage());
                return null;
            }

            @Override
            public R<FlightOrderInfo> getInfo(@RequestBody Map<String, Long> map) {
                return R.fail("获取机票订单基本信息详细信息失败" + cause.getMessage());
            }

            @Override
            public R<AjaxResult> edit(FlightOrderInfo flightOrderInfo) {
                return R.fail("修改机票订单基本信息失败" + cause.getMessage());
            }

            @Override
            public List<FlightOrderChange> refundList(@RequestBody Map<String, Object> map) {
                log.error("获取退票订单列表失败", cause.getMessage());
                return null;
            }

            @Override
            public List<FlightOrderInfo> payList(Map<String, Object> map) {
                log.error("获取支付订单列表失败", cause.getMessage());
                return null;
            }

            @Override
            public List<FlightOrderInfoTickets> orderInfoTicketsList(FlightOrderInfoTickets flightOrderInfoTickets) {
                log.error("查询机票预订_机票订单机票明细列表失败", cause.getMessage());
                return null;
            }

            @Override
            public List<FlightOrderChangeTickets> orderChangeTicketsList(FlightOrderChangeTickets flightOrderChangeTickets) {
                log.error("查询机票预订_机票退改签订单机票信息列表失败", cause.getMessage());
                return null;
            }

            @Override
            public int backfillTicketNumber(Map<String, Object> map) {
                log.error("回填票号失败", cause.getMessage());
                return 0;
            }

            @Override
            public int backfillRemarks(Map<String, Object> map) {
                log.error("回填备注失败", cause.getMessage());
                return 0;
            }

            @Override
            public String airlinerName(Map<String, Object> map) {
                log.error("获取航空公司名称失败", cause.getMessage());
                return null;
            }

            @Override
            public FlightOrderInfo order(Map<String, Object> map) {
                log.error("获取机票订单id失败", cause.getMessage());
                return null;
            }

            @Override
            public boolean orderDetails(Map<String, Object> map) {
                log.error("票号获取机票订单详细失败", cause.getMessage());
                return false;
            }

            @Override
            public List<FlightOrderListVO> orderList(FlightOrderDTOCRM order) {
                log.error("票号获取机票订单数量失败", cause.getMessage());
                return null;
            }

            @Override
            public List<FlightOrderList> orderListThings()
            {
                return null;
            }

            @Override
            public R<Terminal> flightTerminalGetInfo(Map<String, Object> map) {
                return R.fail("获取航站楼详细信息失败" + cause.getMessage());
            }
        };
    }
}
